function CheckInput()
{
	var txtusername = document.getElementById("txtChuyenManaUserNhanName");
	var txtmana = document.getElementById("txtChuyenManaMana");
	if(txtusername.value == "")
	{
		alert("Vui lòng nhập thông tin người nhận mana!");
		return false;
	}
	if(txtmana.value == "")
	{
		alert("Vui long nhap so mana can chuyen!");
		return false;
	}
	if(isNaN(txtmana.value) != false)
	{
		alert("Số mana không hợp lệ");
		return false;
	}
	return true;
}

var xmlhttp;

function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}
	if (window.ActiveXObject)
	{
		// code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}



function AddTransferMana(userid)
{
	if(CheckInput() == true)
	{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support XML HTTP Request");
		return;
	}

	xmlhttp.onreadystatechange = ResultAddChuyenMana;
	var userchuyen = userid;
	var usernhanname = document.getElementById("txtChuyenManaUserNhanName").value;
	var mana = document.getElementById("txtChuyenManaMana").value;

	var url = "XLChuyenMana.php?userchuyen=" + encodeURIComponent(userchuyen);
	url += "&usernhanname=" + encodeURIComponent(usernhanname);
	url += "&mana=" + encodeURIComponent(mana);
	url += "&t=" + Math.random();
	xmlhttp.open("POST", url, true);
	xmlhttp.send(null);
	}
	else
	{
		return;
	}
}

function ResultAddChuyenMana()
{
	if (xmlhttp.readyState==4 && xmlhttp.status == 200)
	{
		document.getElementById("divResultChuyenMana").innerHTML=xmlhttp.responseText;
	}
}

function xlfocus()
{
	document.getElementById("divResultChuyenMana").innerHTML="<br/>";
}